/***************************************************************************************************
  *Copyright(C),2017-2020,Sumscope
  *FileName	:  FixedNatFutureChartControl
  *Author	:  Givins.zhu
  *Version	:  2.0
  *Date		:  2019/10/12
  *Desc		:  
  *History	:
  *Email    :  Givins.zhu@sumscope.com  
***************************************************************************************************/
#pragma once
#include <QWidget>

class CFixedNatFutureData;
class CFixedFutureChartElement;
class QStylePainter;

class CFixedNatFutureChartControl : public QWidget
{
protected:
	enum emElem{
		ele_Border = 0,
		ele_Vol,
		ele_Point,
		ele_OpenInter,//持仓量
		ele_XPosition,//横坐标
		ele_Max
	};
public:
	CFixedNatFutureChartControl(QWidget* p, CFixedNatFutureData* data, bool isYestoday);
	virtual ~CFixedNatFutureChartControl();
	void onRefresh();

protected:
	void paintEvent(QPaintEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void leaveEvent(QEvent* event) override;
	void resizeEvent(QResizeEvent* event) override;

private:
	void showTips(const QPoint& pt, int curKey = -1);
	int getCurrentPointKey(const QRect& rect);

private:
	bool m_isYesterday;
	CFixedNatFutureData* m_data;
	CFixedFutureChartElement* m_chartElement[ele_Max] = { 0 };
	QRect m_rcMark;
	bool m_isShowCross;
	int m_mousePos;
	int	m_curKey = -1;
};